<template>
  <div ref="wrapper">
      <div>
        <slot></slot>
      </div>
  </div>
</template>

<script>
  import BScroll from 'better-scroll'
  export default{
    data(){
      return{
        scroll:null,
      }
    },
    props:{
      currentprobetype:{
        type:Number,
        default:0
      },
      pullUpLoad:{
        type:Boolean,
        default:true
      }
    },
    mounted() {
      this.scroll = new BScroll(this.$refs.wrapper,{
        probeType:this.currentprobetype,
        pullUpLoad:this.pullUpLoad,
        click:true
      })
      this.scroll.on('scroll',(position)=>{
        this.$emit('showback',position)
      })
      this.scroll.on('scroll',(position)=>{
        this.$emit('showtabcontrol',position)
      })
      this.scroll.on('pullingUp',()=>{
        console.log('上拉加载更多')
        this.$emit('pullupload')
      })
      this.scroll.on('scroll',(position)=>{
        this.$emit('content',position)
      })
    },
    methods:{
      backtotop(x,y,time){
        this.scroll.scrollTo(x,y,time)
      },
      finishpullUp(){
        this.scroll.finishPullUp()
      },
      refresh(){
        if(this.scroll)this.scroll.refresh()
      },
      getY(){
        return this.scroll ? this.scroll.y:0
      },
      scrollTo(x,y,time){
        this.scroll.scrollTo(x,y,time)
      }
    }
  }

</script>

<style>

</style>
